<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>考试页面</title>
    <link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
    <style>
        body {
            margin: 0;
            padding: 0;
            height: 100vh;
            width: 100vw;
            background-color: #f8f9fa;
            display: flex;
            justify-content: center;
            align-items: center;
            overflow: hidden;
        }
        .container {
            width: 100%;
            height: 100%;
            background-color: white;
            padding: 30px;
            box-sizing: border-box;
        }
        h1 {
            margin-bottom: 20px;
            font-weight: 300;
            color: #343a40;
            font-size: 2rem;
            text-align: center;
        }
        .exam-content {
            background-color: #e9ecef;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 30px;
            color: #343a40;
            font-size: 1.1rem;
        }
        .btn {
            background-color: #007bff;
            color: white;
            border-radius: 4px;
            width: 100%;
            font-size: 1.2rem;
            padding: 15px;
        }
        .btn:hover {
            background-color: #0056b3;
        }
        .header {
            margin-bottom: 20px;
            text-align: right;
            color: #343a40;
            font-size: 1.1rem;
        }
    </style>
    <script>
        let remainingTime = {{ remaining_time }};
        let interval;

        function startTimer() {
            const timerElement = document.getElementById('timer');
            interval = setInterval(() => {
                if (remainingTime > 0) {
                    remainingTime--;
                    const minutes = Math.floor(remainingTime / 60);
                    const seconds = remainingTime % 60;
                    timerElement.textContent = `剩余时间: ${minutes} 分钟 ${seconds} 秒`;
                } else {
                    clearInterval(interval);
                    alert("考试时间到，系统将自动提交。");
                    document.getElementById('examForm').submit();
                }
            }, 1000);
        }

        window.onload = startTimer;

        function submitExam() {
            clearInterval(interval);
            document.getElementById('examForm').submit();
        }
    </script>
</head>
<body>
    <div class="container">
        <div class="header">
            <span id="timer">剩余时间: 正在计算...</span>
        </div>

        <h1>考试页面</h1>
        <div class="exam-content">
            <p>考试题目示例：这是一个样例题目。请在此处填写您的答案。</p>
        </div>

        <form id="examForm" method="POST" action="{{ url_for('submit_exam', class_name=class_name, exam_name=exam_name) }}">
            <button type="button" onclick="submitExam()" class="btn">提交考试</button>
        </form>
    </div>
</body>
</html>
